package com.wm.task2;

import java.lang.reflect.Array;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {

        Student[] students = {new Student("张四", 100),
                new Student("张三", 80),
                new Student("张五", 80),
                new Student("张七", 90),
                new Student("张六", 70)};
        System.out.println("排序前:");
        for (Student student : students) {
            System.out.println(student.getName() + " " + student.getScore());
        }
        Arrays.sort(students,(s1,s2)->{
            if (s2.getScore()>s1.getScore()){
                return Integer.compare(s2.getScore(), s1.getScore());
            }else{
                return s1.getName().compareTo(s2.getName());
            }
        });

        System.out.println("排序后:");
        for (Student student : students) {
            System.out.println(student.getName() + " " + student.getScore());
        }
    }

}
